<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <form action="https://www.baidu.com">
    <button type="submit">登录</button>
  </form>
  <script>
    const form = document.querySelector('form')
    form.addEventListener('submit',function(e){
      // 阻止默认行为
      e.preventDefault()
    })
  </script>
</body>
</html>